<?
	$tovar_tmb_dir = "/user/images/";
	$tovar_img_dir = "/user/tovar/";
?>
<!-- table begin -->
<table class="products" cellspacing="0" cellpadding="0">
<tr>
	<td style="width:64px;"> </td>
	<td style="width:64px;"> </td>
	<td style="width:64px;"> </td>
	<td style="width:64px;"> </td>
	<td style="width:64px;"> </td>
	<td style="width:64px;"> </td>
	<td style="width:64px;"> </td>
	<td style="width:64px;"> </td>
	<td style="width:64px;"> </td>
	<td style="width:64px;"> </td>
	<td style="width:64px;"> </td>
	<td style="width:64px;"> </td>
</tr>
<?
	function my_split(&$item,$key) {$item = explode(",",$item);}

	$row_cfg = explode(";",$prod_num_on_line);
	array_walk($row_cfg,'my_split');
//	echo "<pre>"; print_r ($row_cfg); echo "</pre>";

	$cfg_line_id = 0; // id строки конфига
	$item_row_id = 1; // номер элемента в строке
	$row_id = 1; // id номер строки в текущем наборе

	include ('user/counter.php');
	$item_ids=explode(",",$tovar_ids_string);
	$field_kind = array('name','desc','old','new');

	foreach ($item_ids as $item_id) {
		if ($is_global) {
			$item2show[${"tovar_".$item_id."_g_pos"}] = $item_id;
			foreach ($field_kind as $fk) ${"tovar_".$item_id."_".$fk} = htmlspecialchars_decode(${"tovar_".$item_id."_".$fk});
		} else {
			if (${"tovar_".$item_id."_category"}==$current_category) {
				$item2show[${"tovar_".$item_id."_cat_pos"}] = $item_id;
				foreach ($field_kind as $fk)
					${"tovar_".$item_id."_".$fk} = htmlspecialchars_decode(${"tovar_".$item_id."_".$fk});
			}
		}
	}

if (!empty($item2show)) {
	ksort($item2show,SORT_NUMERIC);
	foreach ($item2show as $item_id) {
		if (${"tovar_".$item_id."_std_price_name"} === "0") {
			$np_names = true;
		} else {
			$np_names = false;
		}
		$colspan = ''; $rowspan = '';
		switch ($row_cfg[$cfg_line_id][0]) {
			case 1:
			if (${"tovar_".$item_id."_show_old"}) {				$rowspan = 5;			} else {				$rowspan = 4;			}
?>
		<? if ($item_row_id == 1) echo '<tr>'; ?>
		<td colspan="12" class="product" height="370px">
		<table border="0" class="size1 tovar" cellspacing="0" cellpadding="0">
			<tr><td class="top-left"></td><td colspan="2" class="top"></td><td class="top-right"></td></tr>
			<tr>
				<td class="left" rowspan="<?=$rowspan?>"></td>
				<td rowspan="<?=$rowspan?>" width="60%">
					<? $item_img = ${"tovar_".$item_id."_img"};
					if (strpos($item_img,"W#") !== 0) $img_style="height:345px;";
					else {$img_style="width:400px;"; $item_img = substr($item_img,2);} ?>
					<a id="prod_img" href="<?=$tovar_img_dir?>/<?=$item_img?>" title="<?=${"tovar_".$item_id."_desc"}?>">
					<img class="prod_main" style="<?=$img_style?>" src="<?=$tovar_tmb_dir?>/tovar_tmb/<?=$item_img?>" border="0">
					</a>
				</td>
				<td class="item-name" id="item<?=$item_id?>"><?=${"tovar_".$item_id."_name"}?></td>
				<td class="right" rowspan="<?=$rowspan?>"></td>
			</tr>
			<tr><td class="item-desc"><?=${"tovar_".$item_id."_desc"}?></td></tr>
			<? if (${"tovar_".$item_id."_show_old"}) {?>
			<tr><td class="item-old-price"><?=$np_names?${"tovar_".$item_id."_old_name"}:$old_price_name?> <span style="text-decoration: line-through;"><?=${"tovar_".$item_id."_old"}.$currency?></span></td></tr>
			<? } ?>
			<tr><td class="item-new-price"><?=$np_names?${"tovar_".$item_id."_new_name"}:$new_price_name?> <?=${"tovar_".$item_id."_new"}.$currency?></td></tr>
			<tr><td class="item-buy">
				<a class="button" id="inline1" href="#buy-item" style="width:110px;float:none;font-size:14px;"
				 onclick="document.getElementById('buy-item-name').innerHTML=document.getElementById('item<?=$item_id?>').innerHTML;
							document.getElementById('buy-item-input').value=document.getElementById('item<?=$item_id?>').innerHTML;">
				<span>Купить</span>
				</a>
			</td></tr>
			<tr><td class="bottom-left"></td><td colspan="2" class="bottom"></td><td class="bottom-right"></td></tr>
		</table>
		</td>
<?
			break;
			case 2:
?>
		<? if ($item_row_id == 1) echo '<tr>'; ?>
		<td colspan="6" class="product">
		<table border="0" class="tovar size2" cellspacing="0" cellpadding="0">
			<tr><td class="top-left"></td><td colspan="2" class="top"></td><td class="top-right"></td></tr>
			<tr><td class="left" rowspan="4"></td>
			<td class="item-name" colspan="2" id="item<?=$item_id?>"><?=${"tovar_".$item_id."_name"}?></td>
			<td class="right" rowspan="4"></tr>
			<tr><td colspan="2" class="item-img">
			<? $item_img = ${"tovar_".$item_id."_img"};
			if (strpos($item_img,"W#") !== 0) $img_style="height:220px;";
			else {$img_style="width:290px;"; $item_img = substr($item_img,2);} ?>
			<a id="prod_img" href="<?=$tovar_img_dir?>/<?=$item_img?>" title="<?=${"tovar_".$item_id."_desc"}?>">
			<img class="prod_main" style="<?=$img_style?>" src="<?=$tovar_tmb_dir?>/tovar_tmb/<?=strtolower($item_img)?>" border="0">
			</a>
			</td></tr>
			<tr>
			<? if (${"tovar_".$item_id."_show_old"}) {?>
			<td class="item-old-price"><?=$np_names?${"tovar_".$item_id."_old_name"}:$old_price_name?><br><span style="text-decoration: line-through;"><?=${"tovar_".$item_id."_old"}.$currency?></span></td>
			<?} else $colspan=' colspan="2"';?>
			<td class="item-new-price"<?=$colspan?>><?=$np_names?${"tovar_".$item_id."_new_name"}:$new_price_name?><br><?=${"tovar_".$item_id."_new"}.$currency?></td></tr>
			<tr><td class="item-buy" colspan="2">
				<a class="button" id="inline2" href="#buy-item" style="width:110px;float:none;font-size:14px;"
				onclick="document.getElementById('buy-item-name').innerHTML=document.getElementById('item<?=$item_id?>').innerHTML;
							document.getElementById('buy-item-input').value=document.getElementById('item<?=$item_id?>').innerHTML;">
				<span>Купить</span>
				</a>
			</td></tr>
			<tr><td class="bottom-left"></td><td colspan="2" class="bottom"></td><td class="bottom-right"></td></tr>
		</table>
		</td>
<?
			break;
			case 3:
?>
		<? if ($item_row_id == 1) echo '<tr>'; ?>
		<td colspan="4" class="product">
		<table border="0" class="tovar size3" cellspacing="0" cellpadding="0">
			<tr><td class="top-left"></td><td colspan="2" class="top"></td><td class="top-right"></td></tr>
			<tr><td class="left" rowspan="4"></td>
			<td class="item-name" colspan="2" id="item<?=$item_id?>"><?=${"tovar_".$item_id."_name"}?></td>
			<td class="right" rowspan="4"></tr>
			<tr><td class="img-td" colspan="2">
			<? $item_img = ${"tovar_".$item_id."_img"};
			if (strpos($item_img,"W#") !== 0) $img_style="height:160px;";
			else {$img_style="width:220px;"; $item_img = substr($item_img,2);} ?>
			<a id="prod_img" href="<?=$tovar_img_dir?>/<?=$item_img?>" title="<?=${"tovar_".$item_id."_desc"}?>">
			<img class="prod_main" style="<?=$img_style?>" src="<?=$tovar_tmb_dir?>/tovar_tmb/<?=strtolower($item_img)?>" border="0">
			</a>
			</td></tr>
			<tr>
			<? if (${"tovar_".$item_id."_show_old"}) {?>
			<td class="item-old-price"><?=$np_names?${"tovar_".$item_id."_old_name"}:$old_price_name?><br><span style="text-decoration: line-through;"><?=${"tovar_".$item_id."_old"}.$currency?></span></td>
			<?} else $colspan=' colspan="2"';?>
			<td class="item-new-price"<?=$colspan?>><?=$np_names?${"tovar_".$item_id."_new_name"}:$new_price_name?><br><?=${"tovar_".$item_id."_new"}.$currency?></td></tr>
			<tr><td class="item-buy" colspan="2">
				<a class="button" id="inline2" href="#buy-item" style="width:110px;float:none;font-size:14px;"
				onclick="document.getElementById('buy-item-name').innerHTML=document.getElementById('item<?=$item_id?>').innerHTML;
							document.getElementById('buy-item-input').value=document.getElementById('item<?=$item_id?>').innerHTML;">
				<span>Купить</span>
				</a>
			</td></tr>
			<tr><td class="bottom-left"></td><td colspan="2" class="bottom"></td><td class="bottom-right"></td></tr>
		</table>
		</td>
<?
			break;
			case 4:
?>
		<? if ($item_row_id == 1) echo '<tr>'; ?>
		<td colspan="3" class="product">
		<table border="0" class="tovar size4" cellspacing="0" cellpadding="0">
			<tr><td class="top-left"></td><td class="top"></td><td class="top-right"></td></tr>
			<tr><td class="left" rowspan="4">
			<td class="item-name" id="item<?=$item_id?>"><?=${"tovar_".$item_id."_name"}?></td>
			<td class="right" rowspan="4"></tr>
			<tr><td class="img-td">
			<? $item_img = ${"tovar_".$item_id."_img"};
			if (strpos($item_img,"W#") !== 0) $img_style="height:120px;";
			else {$img_style="width:154px;"; $item_img = substr($item_img,2);} ?>
			<a id="prod_img" href="<?=$tovar_img_dir?>/<?=$item_img?>" title="<?=${"tovar_".$item_id."_desc"}?>">
			<img class="prod_main" style="<?=$img_style?>" src="<?=$tovar_tmb_dir?>/tovar_tmb/<?=strtolower($item_img)?>" border="0">
			</a>
			</td></tr>
			<tr><td class="item-new-price"><?=$np_names?${"tovar_".$item_id."_new4_name"}:$new_price_name_4?><br><?=${"tovar_".$item_id."_new"}.$currency?></td></tr>
			<tr><td class="item-buy">
				<a class="button" id="inline2" href="#buy-item" style="width:110px;float:none;font-size:14px;"
				onclick="document.getElementById('buy-item-name').innerHTML=document.getElementById('item<?=$item_id?>').innerHTML;
							document.getElementById('buy-item-input').value=document.getElementById('item<?=$item_id?>').innerHTML;">
				<span>Купить</span>
				</a>
			</td></tr>
			<tr><td class="bottom-left"></td><td class="bottom"></td><td class="bottom-right"></td></tr>
		</table>
		</td>
<?
			break;
		}

		$item_row_id++;
		if ($item_row_id > $row_cfg[$cfg_line_id][0]) {			echo '</tr>';			$item_row_id = 1;
			$row_id++;
			if ($row_id > $row_cfg[$cfg_line_id][1]) {				$row_id = 1;
				if (!empty($row_cfg[$cfg_line_id+1])) $cfg_line_id++;
//				set_item_size($row_cfg[$cfg_line_id][0],$item_box_style);			}		}
	}
}
	//echo "</tr>";
?>
</table>
<!-- table end -->